package com.mxpio.erp.equipment.service.impl;

import com.mxpio.erp.common.equipment.entity.EquipmentCheckPlan;
import com.mxpio.erp.common.equipment.entity.EquipmentCheckPlanDetail;
import com.mxpio.erp.common.equipment.entity.EquipmentCheckPlanTarget;
import com.mxpio.erp.common.equipment.service.EquipmentCheckPlanService;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.jpa.query.Criteria;
import com.mxpioframework.jpa.query.Operator;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.Collection;

/**
 * @Description: 点巡检计划
 * @Author: jeecg-boot
 * @Date:   2021-09-16
 * @Version: V1.0
 */
@Service
public class EquipmentCheckPlanServiceImpl extends BaseServiceImpl<EquipmentCheckPlan> implements EquipmentCheckPlanService {


	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
        JpaUtil.lind(EquipmentCheckPlanDetail.class).equal("planId", id).delete();
        JpaUtil.lind(EquipmentCheckPlanTarget.class).equal("planId", id).delete();
        delete(EquipmentCheckPlan.class,id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {

        JpaUtil.lind(EquipmentCheckPlanDetail.class).in("planId", idList).delete();
        JpaUtil.lind(EquipmentCheckPlanTarget.class).in("planId", idList).delete();

        Criteria c = Criteria.create().addCriterion("id", Operator.IN, idList);
        deleteBatch(EquipmentCheckPlan.class,c);
	}

}
